package com.ssr.ld.action;

import java.beans.PropertyEditorSupport;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;

import com.ssr.ld.constant.SysConstants;

@Controller
public class BaseAction {

	
	@InitBinder
	protected void initBinder(WebDataBinder binder) {
		binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
			@Override
			public void setAsText(String text)  {
				setValue(null == text ? null : text.length() < 1 ? null : text.trim());
			}
		});
		
	}
	
	@ModelAttribute
	public void initSystemMsg(HttpServletRequest request,
			HttpServletResponse response){
		request.setAttribute("systemVision", SysConstants.SYSTEM_VISION);
		request.setAttribute("systemName", SysConstants.SYSTEM_NAME);
	}
	
}
